﻿using B.S.Database.Domain.Entity;
using B.S.Database.ErrorCode;
using B.S.Database.Interface.Interface;
using B.S.Database.Read.Api.Application.Commands;
using B.S.Database.Read.Api.Application.Commands.Slaughter;
using B.S.Database.Read.Api.Application.Commands.Traceability;
using B.S.Database.Read.Api.Dtos.RequsetDtos;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Database.Read.Api.Controllers
{
    /// <summary>
    /// 控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class ManagementController : ControllerBase
    {
        private readonly IMediator mediator;
        private readonly ILogger<ManagementController> logger;
        public ManagementController(IMediator mediator,ILogger<ManagementController> logger)
        {
            this.mediator = mediator;
            this.logger = logger;
        }
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public Task<Apiresult<UserDtos>> UserLogin([FromQuery]UserLoginCommands request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 商品下拉显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<Apiresult<List<Goods_Infomation>>> GoodShow([FromQuery]GoodShowCommands request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 溯源分页显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<Apiresult<ApiPaging<TraceabilityDtos>>> TraceabilityShow([FromQuery]TraceabilityShowCommands request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 溯源分页反填
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public Task<Apiresult<List<TraceabilityDtos>>> TraceabilityFind([FromQuery]TraceabilityFindCommands request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 屠宰信息显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public Task<Apiresult<List<Slaughter_Information>>> SlaughterShow([FromQuery]SlaughterShowCommands request)
        {
            return mediator.Send(request);
        }
    }
}
